package com.aclever.sys.views;

import com.aclever.resouces.SiteDB;
import com.aclever.resouces.SiteTableModel;
import com.aclever.sys.Parser;
import com.aclever.sys.modules.ButtonEditor;
import com.aclever.sys.modules.ButtonRender;

import javax.swing.*;
import javax.swing.table.TableColumn;
import java.awt.*;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: aclever
 * Date: 23.07.13
 * Time: 22:35
 * To change this template use File | Settings | File Templates.
 */
public class Standart extends JPanel {
    private Parser parser = null;
    public JPanel pane = null;
    public JTable siteTable = null;
    private JPanel bottomPane = null;
    public JButton parseAll = null;
    public JProgressBar progressBar = null;
    public JPanel topPane = null;
    private JScrollPane scrollPane4siteTable;
    public JButton addSite = null;


    public Standart(Parser parser){
        super(new BorderLayout());
        this.parser = parser;





        try {
            SiteTableModel tabmodel = new SiteTableModel(new SiteDB());
            siteTable = new JTable(tabmodel);
            TableColumn tableColumn1 = siteTable.getColumnModel().getColumn(4);
            TableColumn tableColumn2 = siteTable.getColumnModel().getColumn(5);
            tableColumn1.setCellEditor(new ButtonEditor());



            siteTable.getColumnModel().getColumn(1).getCellEditor();




            tableColumn1.setCellRenderer(new ButtonRender());

            tableColumn2.setCellEditor(new ButtonEditor());
            tableColumn2.setCellRenderer(new ButtonRender());





//            siteTable.setBackground(Color.LIGHT_GRAY);
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }



        siteTable.getColumnModel().getColumn(0).setMaxWidth(30);
        siteTable.getColumnModel().getColumn(1).setMaxWidth(600);
        siteTable.getColumnModel().getColumn(2).setMaxWidth(200);
        siteTable.getColumnModel().getColumn(3).setMaxWidth(100);
        siteTable.getColumnModel().getColumn(4).setMaxWidth(150);
        siteTable.getColumnModel().getColumn(5).setMaxWidth(150);

        progressBar = new JProgressBar();






        parseAll = new JButton("Parse All");
        parseAll.addActionListener(parser.getController());



        topPane = new JPanel();
        addSite = new JButton("+");
        addSite.addActionListener(parser.getController());

        topPane.add(new JLabel("Add Site"));
        topPane.add(addSite);





        bottomPane = new JPanel(new BorderLayout());
        bottomPane.add(new JButton("Config"), BorderLayout.WEST);
        bottomPane.add(progressBar, BorderLayout.CENTER);
        bottomPane.add(parseAll, BorderLayout.EAST);


       scrollPane4siteTable = new JScrollPane(siteTable);

        add(topPane, BorderLayout.NORTH);
        add(scrollPane4siteTable, BorderLayout.CENTER);
        add(bottomPane, BorderLayout.SOUTH);



    }



}
